.class public Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;
.super Lorg/jboss/netty/bootstrap/Bootstrap;
.source "ConnectionlessBootstrap.java"


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 125
    invoke-direct {p0}, Lorg/jboss/netty/bootstrap/Bootstrap;-><init>()V

    .line 126
    return-void
.end method

.method public constructor <init>(Lorg/jboss/netty/channel/ChannelFactory;)V
    .locals 0
    .parameter "channelFactory"

    .prologue
    .line 132
    invoke-direct {p0, p1}, Lorg/jboss/netty/bootstrap/Bootstrap;-><init>(Lorg/jboss/netty/channel/ChannelFactory;)V

    .line 133
    return-void
.end method


# virtual methods
.method public bind()Lorg/jboss/netty/channel/Channel;
    .locals 3

    .prologue
    .line 157
    const-string v1, "localAddress"

    invoke-virtual {p0, v1}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->getOption(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/net/SocketAddress;

    .line 158
    .local v0, localAddress:Ljava/net/SocketAddress;
    if-nez v0, :cond_0

    .line 159
    new-instance v1, Ljava/lang/IllegalStateException;

    const-string v2, "localAddress option is not set."

    invoke-direct {v1, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 161
    :cond_0
    invoke-virtual {p0, v0}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->bind(Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/Channel;

    move-result-object v1

    return-object v1
.end method

.method public bind(Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/Channel;
    .locals 8
    .parameter "localAddress"

    .prologue
    .line 174
    if-nez p1, :cond_0

    .line 175
    new-instance v5, Ljava/lang/NullPointerException;

    const-string v6, "localAddress"

    invoke-direct {v5, v6}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V

    throw v5

    .line 180
    :cond_0
    :try_start_0
    invoke-virtual {p0}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->getPipelineFactory()Lorg/jboss/netty/channel/ChannelPipelineFactory;

    move-result-object v5

    invoke-interface {v5}, Lorg/jboss/netty/channel/ChannelPipelineFactory;->getPipeline()Lorg/jboss/netty/channel/ChannelPipeline;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v3

    .line 185
    .local v3, pipeline:Lorg/jboss/netty/channel/ChannelPipeline;
    invoke-virtual {p0}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->getFactory()Lorg/jboss/netty/channel/ChannelFactory;

    move-result-object v5

    invoke-interface {v5, v3}, Lorg/jboss/netty/channel/ChannelFactory;->newChannel(Lorg/jboss/netty/channel/ChannelPipeline;)Lorg/jboss/netty/channel/Channel;

    move-result-object v0

    .line 188
    .local v0, ch:Lorg/jboss/netty/channel/Channel;
    const/4 v4, 0x0

    .line 190
    .local v4, success:Z
    :try_start_1
    invoke-interface {v0}, Lorg/jboss/netty/channel/Channel;->getConfig()Lorg/jboss/netty/channel/ChannelConfig;

    move-result-object v5

    invoke-virtual {p0}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->getOptions()Ljava/util/Map;

    move-result-object v6

    invoke-interface {v5, v6}, Lorg/jboss/netty/channel/ChannelConfig;->setOptions(Ljava/util/Map;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 191
    const/4 v4, 0x1

    .line 193
    if-nez v4, :cond_1

    .line 194
    invoke-interface {v0}, Lorg/jboss/netty/channel/Channel;->close()Lorg/jboss/netty/channel/ChannelFuture;

    .line 199
    :cond_1
    invoke-interface {v0, p1}, Lorg/jboss/netty/channel/Channel;->bind(Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v2

    .line 202
    .local v2, future:Lorg/jboss/netty/channel/ChannelFuture;
    invoke-interface {v2}, Lorg/jboss/netty/channel/ChannelFuture;->awaitUninterruptibly()Lorg/jboss/netty/channel/ChannelFuture;

    .line 203
    invoke-interface {v2}, Lorg/jboss/netty/channel/ChannelFuture;->isSuccess()Z

    move-result v5

    if-nez v5, :cond_3

    .line 204
    invoke-interface {v2}, Lorg/jboss/netty/channel/ChannelFuture;->getChannel()Lorg/jboss/netty/channel/Channel;

    move-result-object v5

    invoke-interface {v5}, Lorg/jboss/netty/channel/Channel;->close()Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v5

    invoke-interface {v5}, Lorg/jboss/netty/channel/ChannelFuture;->awaitUninterruptibly()Lorg/jboss/netty/channel/ChannelFuture;

    .line 205
    new-instance v5, Lorg/jboss/netty/channel/ChannelException;

    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6}, Ljava/lang/StringBuilder;-><init>()V

    const-string v7, "Failed to bind to: "

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-interface {v2}, Lorg/jboss/netty/channel/ChannelFuture;->getCause()Ljava/lang/Throwable;

    move-result-object v7

    invoke-direct {v5, v6, v7}, Lorg/jboss/netty/channel/ChannelException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v5

    .line 181
    .end local v0           #ch:Lorg/jboss/netty/channel/Channel;
    .end local v2           #future:Lorg/jboss/netty/channel/ChannelFuture;
    .end local v3           #pipeline:Lorg/jboss/netty/channel/ChannelPipeline;
    .end local v4           #success:Z
    :catch_0
    move-exception v1

    .line 182
    .local v1, e:Ljava/lang/Exception;
    new-instance v5, Lorg/jboss/netty/channel/ChannelPipelineException;

    const-string v6, "Failed to initialize a pipeline."

    invoke-direct {v5, v6, v1}, Lorg/jboss/netty/channel/ChannelPipelineException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v5

    .line 193
    .end local v1           #e:Ljava/lang/Exception;
    .restart local v0       #ch:Lorg/jboss/netty/channel/Channel;
    .restart local v3       #pipeline:Lorg/jboss/netty/channel/ChannelPipeline;
    .restart local v4       #success:Z
    :catchall_0
    move-exception v5

    if-nez v4, :cond_2

    .line 194
    invoke-interface {v0}, Lorg/jboss/netty/channel/Channel;->close()Lorg/jboss/netty/channel/ChannelFuture;

    .line 193
    :cond_2
    throw v5

    .line 208
    .restart local v2       #future:Lorg/jboss/netty/channel/ChannelFuture;
    :cond_3
    return-object v0
.end method

.method public connect()Lorg/jboss/netty/channel/ChannelFuture;
    .locals 3

    .prologue
    .line 235
    const-string v1, "remoteAddress"

    invoke-virtual {p0, v1}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->getOption(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/net/SocketAddress;

    .line 236
    .local v0, remoteAddress:Ljava/net/SocketAddress;
    if-nez v0, :cond_0

    .line 237
    new-instance v1, Ljava/lang/IllegalStateException;

    const-string v2, "remoteAddress option is not set."

    invoke-direct {v1, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 239
    :cond_0
    invoke-virtual {p0, v0}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->connect(Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v1

    return-object v1
.end method

.method public connect(Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/ChannelFuture;
    .locals 3
    .parameter "remoteAddress"

    .prologue
    .line 265
    if-nez p1, :cond_0

    .line 266
    new-instance v1, Ljava/lang/NullPointerException;

    const-string v2, "remotedAddress"

    invoke-direct {v1, v2}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 268
    :cond_0
    const-string v1, "localAddress"

    invoke-virtual {p0, v1}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->getOption(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/net/SocketAddress;

    .line 269
    .local v0, localAddress:Ljava/net/SocketAddress;
    invoke-virtual {p0, p1, v0}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->connect(Ljava/net/SocketAddress;Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v1

    return-object v1
.end method

.method public connect(Ljava/net/SocketAddress;Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/ChannelFuture;
    .locals 6
    .parameter "remoteAddress"
    .parameter "localAddress"

    .prologue
    .line 287
    if-nez p1, :cond_0

    .line 288
    new-instance v4, Ljava/lang/NullPointerException;

    const-string v5, "remoteAddress"

    invoke-direct {v4, v5}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V

    throw v4

    .line 293
    :cond_0
    :try_start_0
    invoke-virtual {p0}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->getPipelineFactory()Lorg/jboss/netty/channel/ChannelPipelineFactory;

    move-result-object v4

    invoke-interface {v4}, Lorg/jboss/netty/channel/ChannelPipelineFactory;->getPipeline()Lorg/jboss/netty/channel/ChannelPipeline;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v2

    .line 299
    .local v2, pipeline:Lorg/jboss/netty/channel/ChannelPipeline;
    invoke-virtual {p0}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->getFactory()Lorg/jboss/netty/channel/ChannelFactory;

    move-result-object v4

    invoke-interface {v4, v2}, Lorg/jboss/netty/channel/ChannelFactory;->newChannel(Lorg/jboss/netty/channel/ChannelPipeline;)Lorg/jboss/netty/channel/Channel;

    move-result-object v0

    .line 300
    .local v0, ch:Lorg/jboss/netty/channel/Channel;
    const/4 v3, 0x0

    .line 302
    .local v3, success:Z
    :try_start_1
    invoke-interface {v0}, Lorg/jboss/netty/channel/Channel;->getConfig()Lorg/jboss/netty/channel/ChannelConfig;

    move-result-object v4

    invoke-virtual {p0}, Lorg/jboss/netty/bootstrap/ConnectionlessBootstrap;->getOptions()Ljava/util/Map;

    move-result-object v5

    invoke-interface {v4, v5}, Lorg/jboss/netty/channel/ChannelConfig;->setOptions(Ljava/util/Map;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 303
    const/4 v3, 0x1

    .line 305
    if-nez v3, :cond_1

    .line 306
    invoke-interface {v0}, Lorg/jboss/netty/channel/Channel;->close()Lorg/jboss/netty/channel/ChannelFuture;

    .line 311
    :cond_1
    if-eqz p2, :cond_2

    .line 312
    invoke-interface {v0, p2}, Lorg/jboss/netty/channel/Channel;->bind(Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/ChannelFuture;

    .line 316
    :cond_2
    invoke-interface {v0, p1}, Lorg/jboss/netty/channel/Channel;->connect(Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v4

    return-object v4

    .line 294
    .end local v0           #ch:Lorg/jboss/netty/channel/Channel;
    .end local v2           #pipeline:Lorg/jboss/netty/channel/ChannelPipeline;
    .end local v3           #success:Z
    :catch_0
    move-exception v1

    .line 295
    .local v1, e:Ljava/lang/Exception;
    new-instance v4, Lorg/jboss/netty/channel/ChannelPipelineException;

    const-string v5, "Failed to initialize a pipeline."

    invoke-direct {v4, v5, v1}, Lorg/jboss/netty/channel/ChannelPipelineException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v4

    .line 305
    .end local v1           #e:Ljava/lang/Exception;
    .restart local v0       #ch:Lorg/jboss/netty/channel/Channel;
    .restart local v2       #pipeline:Lorg/jboss/netty/channel/ChannelPipeline;
    .restart local v3       #success:Z
    :catchall_0
    move-exception v4

    if-nez v3, :cond_3

    .line 306
    invoke-interface {v0}, Lorg/jboss/netty/channel/Channel;->close()Lorg/jboss/netty/channel/ChannelFuture;

    .line 305
    :cond_3
    throw v4
.end method
